//2009/08/07 19:15:26
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
class PaperFold
{
public:
    int numFolds(vector<int> paper, vector<int> box)
    {
        res = -1; // Don't make int res = ***; it will make res localized.
        recursive(paper[0],paper[1],box[0],box[1],0);
        return res ;
    }
    void recursive(double px, double py, double x, double y, int fold)
    {
		if (fold > 8) return; // To avoid the infinite recursive;
        if ((px<=x && py<=y) || (px<=y && py<=x))
        {
            if(res == -1 || res > fold) res = fold;
        }
        recursive(px/2.0,py,x,y,fold+1);
        recursive(px,py/2.0,x,y,fold+1);
    }
private:
    int res;

};
